﻿using System;
using YTE.Control;
using 右下角弹窗.DiagShow;

namespace LD.Host
{
    public partial class FrmPwdEdit : FrmOKCancel
    {
        private TB_User m_user;
        public FrmPwdEdit()
        {
            InitializeComponent();
            this.Shown += FrmShown;
            this.btn_ok.Click += Btn_ok_Click;
        }
        public FrmPwdEdit(TB_User user) : this()
        {
            m_user = user;
            if (m_user != null)
            {
                this.lab_userName.Text =m_user.Name.ToString();
            }
        }
        private void FrmShown(object sender, EventArgs e)
        {
        }

        private void Btn_ok_Click(object sender, EventArgs e)
        {
            if (m_user != null)
            {
                if (!m_user.Pwd.Equals(this.txt_oldPwd.Text))
                {
                    Dialog dialog = new Dialog();
                    dialog.Warning("旧密码错误");
                    return;
                }

                m_user.Pwd = this.txt_newPwd.Text;
             
                Appbus.User.Save(m_user);
            }
            this.Close();
        }
    }
}
